class Solution {
public:
    int diagonalSum(vector<vector<int>>& mat) {
        int n = mat.size(), sum = (n & 1) * mat[n / 2][n / 2];
        for (size_t i = 0; i < n / 2; i++)
        sum += mat[i][i] + mat[n - i - 1][n - i - 1] + mat[i][n - i - 1] + mat[n - i - 1][i];
        return sum;
    }
};